/**
 * 
 */
package com.lostad.app.common.service.impl;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.hlmedicals.app.system.entity.HisDepart;
import com.hlmedicals.app.system.entity.HisDoctor;
import com.hlmedicals.app.system.entity.HisPatient;
import com.hlmedicals.app.system.entity.HisThirdParty;
import com.hlmedicals.app.system.entity.TSType;
import com.hlmedicals.app.system.entity.TSTypegroup;
import com.lostad.app.common.dao.JpaDao;
import com.lostad.app.common.service.CacheService;
import com.lostad.app.common.util.Validator;

/**
 * 用于处理人员信息等缓存数据,
 * 其它缓存数据，如HisDepart直接在类上加的缓存注解。
 * 未提供更新缓存的方法
 * @author sszvip@qq.com
 * 
 */
@Service("cacheService")
@Transactional
public class CacheServiceImpl implements CacheService {
	@Autowired
	private JpaDao jpaDao;
	
	//============用户信息===============================================================
	@org.springframework.cache.annotation.Cacheable(value = "basicCache", key = "#id.concat('_user')")
	public HisDoctor findHisDoctor(String id){
		HisDoctor p = null;
		if(Validator.isNotEmpty(id)){
			p = jpaDao.find(HisDoctor.class, id);
		}
		return p;
	}
	@org.springframework.cache.annotation.CacheEvict(value = "basicCache", key = "#user.id.concat('_user')")
	public void saveHisDoctor(HisDoctor user) {
		jpaDao.save(user);
	}
	
	@org.springframework.cache.annotation.CacheEvict(value = "basicCache", key = "#user.id.concat('_user')")
	public void delHisDoctor(HisDoctor user) {
		jpaDao.delete(user);
	}
	
	//============第三方平台对接===============================================================
	@org.springframework.cache.annotation.Cacheable(value = "basicCache", key = "#appId.concat('_app')")
	public HisThirdParty getHisThirdParty(String appId) {
		return jpaDao.find(HisThirdParty.class,appId);
	}
	
	@org.springframework.cache.annotation.CacheEvict(value = "basicCache", key = "#user.id.concat('_app')")
	public void updateThirdParty(HisThirdParty thirdParty) {
		jpaDao.merge(thirdParty);
	}
	@Override
	public void saveOrUpdateHisPatient(HisPatient hisPatient) {
		// TODO Auto-generated method stub
	}
	@Override
	public void delHisPatient(HisPatient hisPatient) {
		// TODO Auto-generated method stub
		
	}
	@Override
	public HisPatient getHisPatient(String id) {
		// TODO Auto-generated method stub
		return null;
	}
	@Override
	public HisDoctor getHisDoctor(String id) {
		// TODO Auto-generated method stub
		return null;
	}
	@Override
	public void saveOrUpdateHisDoctor(HisDoctor hisDoctor) {
		// TODO Auto-generated method stub
		
	}
	@Override
	public TSTypegroup getTypeGroupByCode(String typegroupcode) {
		// TODO Auto-generated method stub
		return null;
	}
	@Override
	public TSType getTypeByCode(String typegroupcode, String typecode) {
		// TODO Auto-generated method stub
		return null;
	}
	@Override
	public void saveOrUpdateTSType(TSType type) {
		// TODO Auto-generated method stub
		
	}
	@Override
	public List<TSType> listType(String typegroupCode) {
		// TODO Auto-generated method stub
		return null;
	}
	@Override
	public void saveOrUpdateTSTypeGroup(TSTypegroup group) {
		// TODO Auto-generated method stub
		
	}
	@Override
	public HisDepart getHisDepart(String orgid) {
		// TODO Auto-generated method stub
		return null;
	}
	@Override
	public void saveOrUpdateThirdParty(HisThirdParty hisThirdParty) {
		// TODO Auto-generated method stub
		
	}
	@Override
	public void removeTSType(TSType type) {
		// TODO Auto-generated method stub
		
	}

}
